home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / guitarChar.lua < prev    next >
Text File  |  2004-01-29  |  5KB  |  187 lines

  1. -- guitar character state machine
  2. beginStateMachine()
  3.     
  4.     onEnter(function(msg)
  5.         local guitarRack = getStateObjectFromID(msg.sender);
  6.         storeStateObject("guitarRack", guitarRack);
  7.         
  8.         if (guitarRack) then
  9.             -- guitarRack does exist
  10.             if (getParent().isOneActionPointLocked(guitarRack)) then
  11.                 -- action point is locked
  12.                 getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  13.                 sendMsg("emoThink", getParent().walkSO);
  14.                 exitStateMachine();
  15.             else
  16.                 getParent().lockActionPoints(guitarRack);
  17.             end
  18.         else
  19.             -- guitarRack does not exist anymore
  20.             getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  21.             sendMsg("emoThink", getParent().walkSO);
  22.             exitStateMachine();
  23.         end
  24.         
  25.         freeHands(getParent());
  26.                 
  27.     end )
  28.     
  29.     onExit(function(msg)
  30.     
  31.         freeHands(getParent());
  32.         removeStateObject("guitar");
  33.         
  34. --        local guitarRack = retrieveStateObject("guitarRack");
  35. --        getParent().unlockActionPoints(guitarRack);
  36. --        getParent().stopAllActivities(guitarRack);
  37. --        removeStateObject("guitarRack");
  38.         
  39.         unlockAll("guitarRack");        
  40.  
  41.     end )
  42.     
  43.     state("takeGuitar")
  44.     
  45.         onEnter(function(msg)
  46.         
  47.             --startAnimation("playGuitarLoop");
  48.             
  49.             local guitarRack = retrieveStateObject("guitarRack");
  50.             local guitar = guitarRack.createGameObject("guitar");
  51.             storeStateObject("guitar", guitar);
  52.             getParent().attachLeftObjectHolder(guitarRack, "guitar");
  53.             getParent().handSO.setPose("leftHandHoldVert");
  54.             
  55.             setState("lookForSeat");
  56.             
  57.         end )
  58.     
  59.         
  60. --        onMsg("queue", function(msg)
  61. --            getParent().detachLeftObjectHolder();
  62. --            exitStateMachine();
  63. --        end )    
  64. --
  65. --        onMsg("end", function(msg)
  66. --            if testCancel() then
  67. --                getParent().detachLeftObjectHolder();
  68. --                exitStateMachine();
  69. --            else
  70. --                startAnimation("playGuitarLoop");
  71. --            end
  72. --        end )    
  73.         
  74.  
  75. --    state("lookForSeat")
  76. --        print("lookForSeat");
  77. --    
  78. --        onEnter(function(msg)
  79. --            -- find a sofa to play guitar
  80. --            local seat, actionPoint = getNextReadSit(getParent());
  81. --            if (not seat) then
  82. --                sendMsgThis("noPlaceToPlay");
  83. --                return            
  84. --            end
  85. --            
  86. --            local wso = getParent().walkSO;
  87. --            if (wso.walkToActionPoint(actionPoint)) then
  88. --            
  89. --                -- create state machine contexts
  90. --                local wsoContext = StateMachineContext();
  91. --                wsoContext.storeStateObject("seat", seat);
  92. --                wsoContext.storeStateObject("guitarRack", retrieveStateObject("guitarRack"));
  93. --                wsoContext.storeStateObject("guitar", retrieveStateObject("guitar"));
  94. --                wsoContext.storeData("actionPointName", actionPoint.getName());
  95. --                
  96. --                wso.queueStateMachine("sofaGuitarChar.sitDown", this, wsoContext);                
  97. --                exitStateMachine();
  98. --            else
  99. --                print("no path found");
  100. --                character.setEmoticon(EMOTICON_NOPATH, EMOTICON_DELAY);
  101. --                sendMsg("emoThink", character.walkSO);
  102. --                sendMsgThis("noPlaceToPlay");
  103. --            end
  104. --            
  105. --            
  106. --            
  107. --            
  108. --        end)
  109.  
  110.  
  111.  
  112.     state("lookForSeat")
  113.         print("lookForSeat");
  114.     
  115.         onEnter(function(msg)
  116.             -- find a sofa to play guitar
  117.             local seat, actionPoint = getNextReadSit(getParent());
  118.             if (not seat) then
  119.                 sendMsgThis("noPlaceToPlay");
  120.                 return            
  121.             end
  122.             
  123.             --local wso = getParent().walkSO;
  124.             if (walkToPointImmediate(actionPoint)) then
  125.             
  126.                 -- create state machine contexts
  127. --                local wsoContext = StateMachineContext();
  128. --                wsoContext.storeStateObject("seat", seat);
  129. --                wsoContext.storeStateObject("guitarRack", retrieveStateObject("guitarRack"));
  130. --                wsoContext.storeStateObject("guitar", retrieveStateObject("guitar"));
  131. --                wsoContext.storeData("actionPointName", actionPoint.getName());
  132.                 
  133. --                wso.queueStateMachine("sofaGuitarChar.sitDown", this, wsoContext);                
  134. --                exitStateMachine();
  135.  
  136.                 storeStateObject("sofa", seat);
  137.                 storeData("actionPointName", actionPoint.getName());
  138.                 enterStateMachine("subwalk.walk");
  139.             else
  140.                 print("no path found");
  141.                 character.setEmoticon(EMOTICON_NOPATH, EMOTICON_DELAY);
  142.                 sendMsg("emoThink", character.walkSO);
  143.                 sendMsgThis("noPlaceToPlay");
  144.             end
  145.             
  146.         end)
  147.  
  148.         onReturn(function(msg)
  149.             print("lookForSeat onReturn");
  150.             setState("sitAndPlay");
  151.         end)
  152.  
  153.  
  154.  
  155.         onMsg("noPlaceToPlay", function(msg)
  156.         
  157.             print("no place to play");
  158.             -- detach book if attached to left hand
  159. --            getParent().detachLeftObjectHolder();
  160. --            getParent().detachRightObjectHolder();
  161. --            local guitar = retrieveStateObject("guitar");
  162. --            if (guitar) then guitar.deleteGameObject(); end
  163. --            getParent().handSO.stopPose();
  164.             
  165.             getParent().setEmoticon(EMOTICON_NOSOFA, EMOTICON_DELAY);            
  166.             sendMsg("emoThink", getParent().walkSO);
  167.             exitStateMachine();
  168.         end)
  169.  
  170.     state("sitAndPlay")
  171.     
  172.         onEnter(function(msg)
  173.             print("sitAndPlay onEnter");
  174.             storeData("sitState", "playGuitar");
  175.             enterStateMachine("sofaChar.sitDown");
  176. --            enterStateMachine("sofaGuitarChar.sitDown");
  177.         end)
  178.         
  179.         onReturn(function(msg)
  180.             print("sitAndPlay onReturn");
  181.             exitStateMachine();
  182.         end)
  183.  
  184.  
  185.                 
  186. endStateMachine()
  187.